package 古诗词文本处理;

import java.util.Scanner;

public class Poem {
	/*String poem = "汉皇重色思倾国御宇多年求不得杨家有女初长成养在深闺人未识天生丽质难自弃一朝选在君王侧回眸一笑百媚生六宫粉黛无颜色春寒赐浴华清池温泉水滑洗凝脂侍儿扶起娇无力始是新承恩泽时云鬓花颜金步摇芙蓉帐暖度春宵春宵苦短日高起从此君王不早朝承欢侍宴无闲暇春从春游夜专夜后宫佳丽三千人三千宠爱在一身金屋妆成娇侍夜玉楼宴罢醉和春姊妹弟兄皆列士可怜光采生门户遂令天下父母心不重生男重生女骊宫高处入青云仙乐风飘处处闻缓歌慢舞凝丝竹尽日君王看不足渔阳鼙鼓动地来惊破霓裳羽衣曲九重城阙烟尘生千乘万骑西南行";
	String Fix_poem = "";
	int n,m;
	n = poem.length();
	String poem2 = new String(poem);
	System.out.println(poem);*/
	public static void main(String args[]) {
		String p = "汉皇重色思倾国御宇多年求不得杨家有女初长成养在深闺人未识天生丽质难自弃一朝选在君王侧回眸一笑百媚生六宫粉黛无颜色春寒赐浴华清池温泉水滑洗凝脂侍儿扶起娇无力始是新承恩泽时云鬓花颜金步摇芙蓉帐暖度春宵春宵苦短日高起从此君王不早朝承欢侍宴无闲暇春从春游夜专夜后宫佳丽三千人三千宠爱在一身金屋妆成娇侍夜玉楼宴罢醉和春姊妹弟兄皆列士可怜光采生门户遂令天下父母心不重生男重生女骊宫高处入青云仙乐风飘处处闻缓歌慢舞凝丝竹尽日君王看不足渔阳鼙鼓动地来惊破霓裳羽衣曲九重城阙烟尘生千乘万骑西南行";
		int n;
		n = p.length();
		//char poem[] = p.toCharArray();
		char []poem = new char[239];
		for(int i=0;i<p.length();i++) {
			poem = p.toCharArray();
		}
		for(int j=0;j<p.length();j++) {
			//System.out.print(poem[j]);
			
		}
		//String s = new String(poem,0,7);
		//System.out.println("\n"+s);
		//char Poem;
		//Poem = p.charAt(2);
		//System.out.println("\n"+Poem);
		for(int k = 0;k<(n/7);k++) {
			String s = new String(poem,0+7*k,7);
			if(k%2==0) {
				System.out.print(s+",");
			}
			if(k%2!=0) {
				System.out.println(s+"。");
			}
		}
		//判断字符出现的次数
		/*String y = "君";
		char Y[] = y.toCharArray();
		int num = p.indexOf(y);
		for(int l = 0;l<n;l++) {
			if( Y[0] == poem[l]) {
				num = num +1;
			}
		}
		System.out.println(num);*/
		//用户自己输入字符串
		Scanner Obj = new Scanner(System.in);
		System.out.println("请输入要查找的汉字:");
		String y = Obj.nextLine();
		char Y[] = y.toCharArray();
		int m = p.indexOf(y);
		//int m = y.length();
		/*for(int l = 0;l<n;l++) {
			if( Y[0] == poem[l]) {
				num = num +1;
			}
		}*/
		int count = 0;
		while(n>0) {
			int num = p.indexOf(y);
			if(num != -1) {
				count++;
				p = p.substring(num+1);
			}
			else {
				break;
			}
		}
		System.out.println("字符第一次出现位置："+m);
		System.out.println("字符出现的次数："+count);
	}
}
